﻿/**
 * Create in 2012-4-5.
 */
package kit4j.view.cs.swing.window;

import java.awt.Color;
import java.awt.Container;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Window;

import javax.swing.JWindow;

import kit4j.view.cs.component.BackgroundConstraints;
import kit4j.view.cs.component.FullComponent;
import kit4j.view.cs.swing.panel.JFullPanel;

/**
 * 
 * @author MiniKnife
 *
 */
public class JFullWindow extends JWindow implements FullComponent {
	
	private static final long serialVersionUID = 1L;
	
	private JFullPanel contentPane;
	
	public JFullWindow() {
		super();
		init();
	}
	
	/**
	 * @param owner
	 */
	public JFullWindow(Frame owner) {
		super(owner);
		init();
	}

	/**
	 * @param gc
	 */
	public JFullWindow(GraphicsConfiguration gc) {
		super(gc);
		init();
	}

	/**
	 * @param owner
	 * @param gc
	 */
	public JFullWindow(Window owner, GraphicsConfiguration gc) {
		super(owner, gc);
		init();
	}

	/**
	 * @param owner
	 */
	public JFullWindow(Window owner) {
		super(owner);
		init();
	}

	private void init() {
		resetContentPane();;
	}

	private void resetContentPane() {
		contentPane = new JFullPanel();
		setContentPane(contentPane);
	}

	/**
	 * @deprecated 请使用<code>{@link #setContentPane(JFullPanel) setContentPane(JFullPanel)}</code>。
	 * @throws UnsupportedOperationException
	 *             调用方法时，始终抛出该异常，如果需要更换contentPane，请使用
	 *             <code>{@link #setContentPane(JFullPanel) setContentPane(JFullPanel)}</code>。
	 * @see javax.swing.JWindow#setContentPane(java.awt.Container)
	 */
	@Override
	public void setContentPane(Container contentPane) throws UnsupportedOperationException {
		throw new UnsupportedOperationException(getClass().getCanonicalName()
				+ ".setContentPane(Container) is unsupported.");
	}

	/**
	 * @see javax.swing.JWindow#setContentPane(Container)
	 */
	public void setContentPane(JFullPanel contentPane) {
		this.contentPane = contentPane;
		super.setContentPane(contentPane);
	}

	@Override
	public void setBackgroundImage(Image img) {
		this.contentPane.setBackgroundImage(img);
	}

	@Override
	public Image getBackgroundImage() {
		return this.contentPane.getBackgroundImage();
	}

	@Override
	public BackgroundConstraints getBackgroundConstraints() {
		return this.contentPane.getBackgroundConstraints();
	}

	@Override
	public void setBackgroundConstraints(BackgroundConstraints bgc) {
		this.contentPane.setBackgroundConstraints(bgc);
	}

	@Override
	public void setAutoGenerateComponentsBackgroundImage(boolean autoGenerateComponentsBackgroundImage) {
		this.contentPane.setAutoGenerateComponentsBackgroundImage(autoGenerateComponentsBackgroundImage);
	}

	@Override
	public boolean isAutoGenerateComponentsBackgroundImage() {
		return this.contentPane.isAutoGenerateComponentsBackgroundImage();
	}
	
	@Override
	public void validate() {
		getContentPane().validate();
		super.validate();
	}
	
	@Override
	public void setBackground(Color color) {
		getContentPane().setBackground(color);
	}
}
